﻿<?php

$url='https://www.360kan.com/dianshi/list.php';
    $源码=获取数据($url,array());
  	$正则='/<div class=\"s-tab-main\">(.*?)<div class=\"s-common-body\">/is';
  	$取链接正则='/class=\"s1\">(.*?)<\/span>/is';
        $取链接1 = '/<p class=\"star\">(.*?)<\/p>/is ';
        $取链接2 = '/href=\"(.*?)\">/is ';
        $取链接3 = '/src=\"(.*?)\">/is ';
        $取链接4 = '/<span class=\"hint\">(.*?)<\/span>/is ';

  	preg_match_all($正则,$源码,$arr);
  	preg_match_all($取链接正则,$arr[0][0],$arr2);
  	preg_match_all($取链接1,$arr[0][0],$arr3);
  	preg_match_all($取链接2,$arr[0][0],$arr4);
  	preg_match_all($取链接3,$arr[0][0],$arr5);
  	preg_match_all($取链接4,$arr[0][0],$arr6);
  	echo "{\"data\":[";
  	for($i=0;$i<count($arr2[1]);$i++){
  	echo "{\"视频名字\":\"";
  	echo($arr2[1][$i]);
  	echo "\",";
  	echo "\"演员\":\"";
  	echo($arr3[1][$i]);
  	echo "\",";
  	echo "\"视频地址\":\"";
  	echo($arr4[1][$i]);
  	echo "\",";
  	echo "\"图片地址\":\"";
  	echo($arr5[1][$i]);
  	echo "\",";
  	echo "\"视频动态\":\"";
  	echo($arr6[1][$i]);
  	echo "\"},";
  	}
  	echo "]}";
//网络操作
function 获取数据($url,$headers){
  	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
  	curl_setopt($ch, CURLOPT_HEADER, 0);
  	curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);
  	curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
	//设置获取的信息以文件流的形式返回，而不是直接输出。
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	$result = curl_exec($ch);
  	curl_close($ch);
  	return $result;
}

?>